<template>
    <a-form-item field="goodsType" label="产品类型">
      <goodsType ref="goodsTypeRef" @success="() => goodsTypeRef.refresh()" />
    </a-form-item>
    <a-form-item field="goods_name3" label="商品名称"   :rules="[{ required: true, message: 'APP ID必填' }]">
      <a-input v-model.trim="forms.goods_name3"   />
    </a-form-item>
  <a-form-item field="categorys" label="商品分类">
    <a-select v-model="forms.categorys" multiple>
      <a-option
          v-for="item in categorysList"
          :key="item"
          :value="item.value"
      >
        {{ item.name }}
      </a-option>
    </a-select>
  </a-form-item>
    <a-form-item field="imagesIds" label="商品图片">
      <ma-upload v-model="forms.imagesIds"  returnType="url" :multiple="true"/>
    </a-form-item>
  <a-form-item field="goods_no" label="编号">
    <a-input v-model="forms.goods_no" />
  </a-form-item>

  <a-form-item field="is_ind_delivery_type" label="运费险">
    <a-select v-model="forms.is_ind_delivery_type">
      <a-option
          v-for="item in serviceList"
          :key="item"
          :value="item.value"
      >
        {{ item.name }}
      </a-option>
    </a-select>
  </a-form-item>
  <a-form-item field="status" label="商品状态">

    <a-radio-group v-model="forms.status">
      <a-radio value="1" :default-checked="true" >上架</a-radio>
      <a-radio value="2">下架</a-radio>
    </a-radio-group>
  </a-form-item>
  <a-form-item field="sort" label="商品排序">
  <a-input-number
      :default-value="forms.sort"
      mode="button"
      @change="changeSort($event, forms.sort)"
      :min="0"
      :max="1000"
  />
  </a-form-item>
</template>

<script setup name="BasicInfo">
import goodsCategory from '@/api/goods/goodsCategory'
import goodsService from '@/api/goods/goodsService'
import goodsType from './goodsType.vue'
import useHepler from '../hooks/useHelper.js'
import goodsInfo from '@/api/goods/goodsInfo'
import {onMounted,ref} from "vue";
const { formRef, forms, rules } = useHepler()

const categorysList = ref([])
const serviceList = ref([])

onMounted(() => {
  console.log('-------------1------------');
  //初始化产品分类
  goodsCategory.list({}).then(res => {
     categorysList.value=res.data;
  })

  goodsService.list({}).then(res => {
    serviceList.value=res.data;
  })
});
</script>
